<template>
  <div class="gift">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="#FE9200">
      <van-swipe-item v-for="(item, index) in bannerList" :key="index">
        <img :src="item" alt="" />
      </van-swipe-item>
    </van-swipe>
    <div class="product">
      <div class="product-detail">
        <div class="left">
          <div class="price">
            <div class="present-price">
              ¥ <span>{{ product.price }}</span>
            </div>
            <div class="before-price">¥999</div>
          </div>
          <p class="product-name">企业服务礼包</p>
        </div>
        <van-button class="buy-btn" round color="#FE9200" @click="routerTo(`/confirmOrder?totalFee=${product.price}`, true)">立即购买</van-button>
      </div>
      <div class="sell-count">
        <span>已售9568</span>
        <span>包邮</span>
      </div>
      <p class="note">3天内发货 不支持7天无理由退货</p>
    </div>
    <div class="good-detail">
      <div class="good-title">
        <span>商品详情</span>
      </div>
      <div class="good-imgs">
        <img src="@assets/images/gift01.jpg" alt="" />
        <img src="@assets/images/gift02.jpg" alt="" />
        <img src="@assets/images/gift03.jpg" alt="" />
        <img src="@assets/images/gift04.jpg" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
import { Button, Toast, Swipe, SwipeItem } from 'vant';
import { product_getProductDetailNew } from '@api/service';
export default {
  components: {
    'van-button': Button,
    [Swipe.name]: Swipe,
    [SwipeItem.name]: SwipeItem
  },
  data() {
    return {
      product: {},
      bannerList: ['https://tyqf-bucket.oss-cn-beijing.aliyuncs.com/other/commodity-1.jpg', 'https://tyqf-bucket.oss-cn-beijing.aliyuncs.com/other/commodity-2.jpg']
    };
  },
  mounted() {
    this.getProductPrice();
  },
  methods: {
    async getProductPrice() {
      let res = await product_getProductDetailNew({ id: 23 });
      if (res.code === 200) {
        let obj = {};
        res.data.attrList.forEach(todo => {
          obj[todo.key] = todo.value;
        });
        this.product = {
          ...res.data,
          ...obj
        };
      } else {
        Toast(res.msg);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.my-swipe {
  width: 750px;
  height: 700px;
  img {
    width: 750px;
    height: 700px;
  }
}
.product {
  padding: 54px 32px 35px;
  background: #fff;
  margin-bottom: 15px;
  &-detail {
    display: flex;
    justify-content: space-between;
  }
  .price {
    display: flex;
    align-items: flex-end;
    color: #828c9e;
    font-size: 26px;
    .present-price {
      color: #eb2e28;
      font-size: 30px;
      font-weight: bold;
      margin-right: 25px;
      span {
        font-size: 50px;
      }
    }
    .before-price {
      position: relative;
      top: -4px;
      text-decoration: line-through;
    }
  }
  .product-name {
    color: #282e3c;
    font-size: 30px;
    margin: 25px 0;
  }
  .sell-count {
    display: flex;
    justify-content: space-between;
    font-size: 24px;
    color: #828c9e;
  }
  .note {
    font-size: 26px;
    color: #282e3c;
    margin-top: 28px;
  }
  .buy-btn {
    width: 250px;
    height: 70px;
    line-height: 70px;
    font-weight: bold;
  }
}
.good-title {
  background: #fff;
  padding: 30px 38px 0;
  span {
    display: inline-block;
    font-weight: bold;
    line-height: 60px;
    font-size: 26px;
    color: #282e3c;
    border-bottom: 8px solid #f09637;
  }
}
.good-imgs {
  font-size: 0;
  img {
    width: 100%;
  }
}
</style>
